package fr.mav.gamecardcounter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

/**
 * Created by Quentin on 29/07/13.
 */
public class ScoreAdapter extends ArrayAdapter<Round> {

    Context context;
    int layoutResourceId;
    ArrayList<Round> rounds = null;

    public ScoreAdapter(Context context, ArrayList<Round> rounds){
        super(context, 0,rounds);
        this.context = context;
        this.rounds = rounds;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            convertView = inflater.inflate(R.layout.adapter_score_line, parent, false);
        }

        Round c = rounds.get(position);

        TextView roundNbTextView = (TextView) convertView.findViewById(R.id.round_nb);
        roundNbTextView.setText(String.valueOf(c.getNbRound()));
        TextView scoreTeam1TextView = (TextView) convertView.findViewById(R.id.current_score_team1);
        scoreTeam1TextView.setText(String.valueOf(c.getScoreTeam1()));
        TextView scoreTeam2TextView = (TextView) convertView.findViewById(R.id.current_score_team2);
        scoreTeam2TextView.setText(String.valueOf(c.getScoreTeam2()));

        return convertView;
    }
}

